﻿namespace Cos.Module.CMS
{
    using Cos.Core.Model.Common;
    using Cos.Core.Model.Content;
    using Cos.Module.CMS.Data;

    /// <summary>
    /// The Menu Service.
    /// </summary>
    public class MenuService : IMenuService
    {
        /// <summary>
        /// private MenuRepository memeber.
        /// </summary>
        private readonly IMenuRepository menuRepository;


        /// <summary>
        /// Initializes a new instance of the <see cref="MenuService"/> class.
        /// </summary>
        /// <param name="menuRepository">The menu repository.</param>
        public MenuService(IMenuRepository menuRepository)
        {
            this.menuRepository = menuRepository;
        }


        /// <summary>
        /// Gets the root menu.
        /// </summary>
        /// <param name="culture">The culture object.</param>
        /// <param name="isLiveMode">if set to <c>true</c> [is live mode].</param>
        /// <returns>
        /// The root menu and the list of sub page and throws UnknownMenuException if the menu doesn't exist
        /// </returns>
        public Menu GetRootMenu(Culture culture, bool isLiveMode)
        {
            return this.menuRepository.GetMenu(null, culture, isLiveMode);
        }

        /// <summary>
        /// Gets the menu.
        /// </summary>
        /// <param name="name">The name of the menu.</param>
        /// <param name="culture">The culture of the page.</param>
        /// <param name="isLiveMode">if set to <c>true</c> [is live mode].</param>
        /// <returns>
        /// The root menu and the list of sub page and throws UnknownMenuException if the menu doesn't exist
        /// </returns>
        public Menu GetMenu(string name, Culture culture, bool isLiveMode)
        {
            return this.menuRepository.GetMenu(name, culture, isLiveMode);
        }
    }
}
